import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home.vue'
import About from './views/About.vue'
import User from './views/User.vue'
// 将Router全局引入vue中
Vue.use(Router)

// 定义路由匹配规则
const routes = [
  {
    path: '/',
    component: Home
  },
  {
    path: '/home',
    component: Home
  },
  {
    path: '/about',
    component: About
  },
  {
    path: '/user/:id',
    component: User
  }
]

// 导出路由对象
export default new Router({
  mode: 'history',
  base: process.env.BASE_URL,
  // 将上述定义的规则设置给路由对象
  routes: routes
})
